package com.mapper;

import com.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    // 查询所有学生
    @Select("select * from student;")
    List<Student> selectAllStudents();

    // 按id查询一个学生
    @Select("select * from student where studentId = #{studentId};")
    Student selectOneStudentById(int id);

    // 按 name 查询学生
    @Select("select * from student where studentName like '%${studentName}%';")
    List<Student> selectOneStudentByName(String studentName);

    // 按id删除一个学生
    @Delete("delete from student where studentId = #{studentId};")
    int deleteOneStudent(int id);

    // 按id修改一个学生
    @Update("update student set studentName = #{studentName},classname = #{classname}, classTeacher = #{classTeacher} where studentId = #{studentId};")
    int updateOneStudent(Student student);

    // 新增一个学生
    @Insert("insert into student (studentName, classname, classTeacher) values (#{studentName},#{classname},#{classTeacher})")
    int insertOneStudent(Student student);
}
